package cms_article

import (
	partner "gitee.com/binny_w/gin-partner"
	"gitee.com/binny_w/gin_starter/core"
)

var MdlCmsArticle *partner.TableModel

func init() {
	core.WaitCore.Wait()
	alias := "article"
	MdlCmsArticle = partner.NewTableModel(core.CmsArticle, alias, nil)
	MdlCmsArticle.OrderByDefault = "`is_top` DESC, `rank` DESC, `id` DESC"
	defer core.Engine.RouterWithModel(core.ApiGroup, MdlCmsArticle)

	MdlCmsArticle.InsertFixer = insertFixer
	MdlCmsArticle.InfoFixer = infoFixer
	MdlCmsArticle.UpdateFixer = updateFixer
	MdlCmsArticle.ListFixer = ListFixer
	MdlCmsArticle.QueryFixer = queryFixer

	MdlCmsArticle.OrderBys["created_asc"] = "created_at asc"
	MdlCmsArticle.OrderBys["created_desc"] = "created_at desc"
	MdlCmsArticle.OrderBys["updated_asc"] = "updated_at asc"
	MdlCmsArticle.OrderBys["updated_desc"] = "updated_at desc"

	MdlCmsArticle.SoColumns = append(MdlCmsArticle.SoColumns, "title", "source", "author", "tags", "content", "created_by", "updated_by")
}
